package com.tjzx.dao;

import java.util.List;
import java.util.Set;
import org.hibernate.LockMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.tjzx.entity.EipUnitedEmployee;

/**
 * A data access object (DAO) providing persistence and search support for
 * EipUnitedEmployee entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.tjzx.entity.EipUnitedEmployee
 * @author MyEclipse Persistence Tools
 */

public class EipUnitedEmployeeDAO extends HibernateDaoSupport {
	private static final Logger log = LoggerFactory
			.getLogger(EipUnitedEmployeeDAO.class);
	// property constants
	public static final String EMPLOYEE_NO = "employeeNo";
	public static final String LOGIN_NAME = "loginName";
	public static final String EMPLOYEE_NAME = "employeeName";
	public static final String MAIL = "mail";
	public static final String OUTTER_MAIL = "outterMail";
	public static final String EMPLOYEE_DUTY = "employeeDuty";
	public static final String EMPLOYEE_LEVEL = "employeeLevel";
	public static final String EMPLOYEE_ORDER = "employeeOrder";
	public static final String MOBILE = "mobile";
	public static final String SHORT_CODE = "shortCode";
	public static final String EMPLOYEE_TYPE_NO = "employeeTypeNo";
	public static final String EMPLOYEE_STATUS = "employeeStatus";
	public static final String EMPLOYEE_ID_CODE = "employeeIdCode";
	public static final String BIRTHDAY = "birthday";
	public static final String EMPLOY_DATE = "employDate";
	public static final String DISPATCH_STATUS = "dispatchStatus";
	public static final String TEL = "tel";
	public static final String FAX = "fax";
	public static final String ADDRESS = "address";
	public static final String NATIVE_ = "native_";
	public static final String PASSWORD = "password";
	public static final String SIGN_DATE = "signDate";
	public static final String REMARK = "remark";
	public static final String ISDEL = "isdel";

	protected void initDao() {
		// do nothing
	}

	public void save(EipUnitedEmployee transientInstance) {
		log.debug("saving EipUnitedEmployee instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(EipUnitedEmployee persistentInstance) {
		log.debug("deleting EipUnitedEmployee instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public EipUnitedEmployee findById(java.lang.Integer id) {
		log.debug("getting EipUnitedEmployee instance with id: " + id);
		try {
			EipUnitedEmployee instance = (EipUnitedEmployee) getHibernateTemplate()
					.get("com.tjzx.entity.EipUnitedEmployee", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(EipUnitedEmployee instance) {
		log.debug("finding EipUnitedEmployee instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding EipUnitedEmployee instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from EipUnitedEmployee as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByEmployeeNo(Object employeeNo) {
		return findByProperty(EMPLOYEE_NO, employeeNo);
	}

	public List findByLoginName(Object loginName) {
		return findByProperty(LOGIN_NAME, loginName);
	}

	public List findByEmployeeName(Object employeeName) {
		return findByProperty(EMPLOYEE_NAME, employeeName);
	}

	public List findByMail(Object mail) {
		return findByProperty(MAIL, mail);
	}

	public List findByOutterMail(Object outterMail) {
		return findByProperty(OUTTER_MAIL, outterMail);
	}

	public List findByEmployeeDuty(Object employeeDuty) {
		return findByProperty(EMPLOYEE_DUTY, employeeDuty);
	}

	public List findByEmployeeLevel(Object employeeLevel) {
		return findByProperty(EMPLOYEE_LEVEL, employeeLevel);
	}

	public List findByEmployeeOrder(Object employeeOrder) {
		return findByProperty(EMPLOYEE_ORDER, employeeOrder);
	}

	public List findByMobile(Object mobile) {
		return findByProperty(MOBILE, mobile);
	}

	public List findByShortCode(Object shortCode) {
		return findByProperty(SHORT_CODE, shortCode);
	}

	public List findByEmployeeTypeNo(Object employeeTypeNo) {
		return findByProperty(EMPLOYEE_TYPE_NO, employeeTypeNo);
	}

	public List findByEmployeeStatus(Object employeeStatus) {
		return findByProperty(EMPLOYEE_STATUS, employeeStatus);
	}

	public List findByEmployeeIdCode(Object employeeIdCode) {
		return findByProperty(EMPLOYEE_ID_CODE, employeeIdCode);
	}

	public List findByBirthday(Object birthday) {
		return findByProperty(BIRTHDAY, birthday);
	}

	public List findByEmployDate(Object employDate) {
		return findByProperty(EMPLOY_DATE, employDate);
	}

	public List findByDispatchStatus(Object dispatchStatus) {
		return findByProperty(DISPATCH_STATUS, dispatchStatus);
	}

	public List findByTel(Object tel) {
		return findByProperty(TEL, tel);
	}

	public List findByFax(Object fax) {
		return findByProperty(FAX, fax);
	}

	public List findByAddress(Object address) {
		return findByProperty(ADDRESS, address);
	}

	public List findByNative_(Object native_) {
		return findByProperty(NATIVE_, native_);
	}

	public List findByPassword(Object password) {
		return findByProperty(PASSWORD, password);
	}

	public List findBySignDate(Object signDate) {
		return findByProperty(SIGN_DATE, signDate);
	}

	public List findByRemark(Object remark) {
		return findByProperty(REMARK, remark);
	}

	public List findByIsdel(Object isdel) {
		return findByProperty(ISDEL, isdel);
	}

	public List findAll() {
		log.debug("finding all EipUnitedEmployee instances");
		try {
			String queryString = "from EipUnitedEmployee";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public EipUnitedEmployee merge(EipUnitedEmployee detachedInstance) {
		log.debug("merging EipUnitedEmployee instance");
		try {
			EipUnitedEmployee result = (EipUnitedEmployee) getHibernateTemplate()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(EipUnitedEmployee instance) {
		log.debug("attaching dirty EipUnitedEmployee instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(EipUnitedEmployee instance) {
		log.debug("attaching clean EipUnitedEmployee instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static EipUnitedEmployeeDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (EipUnitedEmployeeDAO) ctx.getBean("EipUnitedEmployeeDAO");
	}
}